/**
 * 
 */

package com.pp.admin.common.client.helper;

import com.google.gwt.user.client.Window.Location;
import com.pp.admin.common.client.AdminLocale;
import com.pp.admin.common.client.PermissionCheck;

/**
 * @author pandurang
 */
public class QueryString {
	
	public static String	PARAM_DOMAIN	= "domain";
	
	public static String	PARAM_LOCALE	= AdminLocale.LOCALE;
	
	public static String	DEFAULT_DOMAIN	= PermissionCheck.APP_DOMAIN;
	
	public static String	DEFAULT_LOCALE	= "en";
	
	private static String	currentLocale	= null;
	
	private static String	currentDomain	= null;
	
	public static String getCurrentDomain() {

		if ( currentDomain == null ) {
			String selectedDomain = Location.getParameter( PARAM_DOMAIN );
			if ( selectedDomain != null && !( "".equals( selectedDomain ) ) ) {
				currentDomain = selectedDomain;
			} else {
				currentDomain = DEFAULT_DOMAIN;
			}
		}
		return currentDomain;
	}
	
	public static String getCurrentLocale() {

		if ( currentLocale == null ) {
			String selectedLocale = Location.getParameter( PARAM_LOCALE );
			if ( selectedLocale != null && !( "".equals( selectedLocale ) ) ) {
				currentLocale = selectedLocale;
			} else {
				currentLocale = DEFAULT_LOCALE;
			}
		}
		return currentLocale;
	}
}
